package com.wk1un2.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wk1un2.entity.ActivitySess;
import com.wk1un2.entity.Evaluate;
import com.wk1un2.entity.Product;
import com.wk1un2.service.ActivitySessService;
import com.wk1un2.service.EvaluateService;
import com.wk1un2.service.ProductService;
import com.wk1un2.util.Result;

/**
 * 活动场次控制器
 * 
 * @author Administrator
 *
 */
@Controller
public class EvaluateController {
	@Autowired
	EvaluateService service;

	@RequestMapping("/Backstage/getAllEvaluate")
	@ResponseBody
	public Object getAll(@RequestParam("page") int page, @RequestParam("limit") int limit,
			 @RequestParam("e_contents") String e_contents) {

		
		if (e_contents == null || e_contents == "") {
			e_contents = null;
		}
		List<Evaluate> ls = service.getAll((page - 1) * limit, limit, e_contents);
		Result res = new Result(0, "", service.count(), ls);
		return res;
	}

//	
	@RequestMapping("/Backstage/addEvaluate")
	@ResponseBody
	public Object add(@RequestParam Map<String, Object> map) {

		System.out.println(map.get("e_contents"));
		int i = service.add(map);
		Result res = new Result(0, "", i, i);
		return res;
	}

//	޸
	@RequestMapping("/Backstage/updateEvaluate")
	@ResponseBody
	public Object update(@RequestParam Map<String, Object> map) {
		System.out.println(map.get("e_contents"));
		int i = service.update(map);
		Result res = new Result(0, "", i, i);
		return res;
	}

//	ɾ
	@RequestMapping("/Backstage/deleteEvaluate")
	@ResponseBody
	public Object delete(@RequestParam("e_id") int e_id) {
		System.out.println(e_id);
		int i = service.delete(e_id);
		Result res = new Result(0, "", i, i);
		return res;
	}
	//修改状态
		@RequestMapping("/Backstage/updateevaluatestate")
		@ResponseBody
		
		public Result updateevaluatestate(Integer e_id, Integer e_state) {
			service.updateevaluatestate(e_id, e_state);
			return Result.ok("0");
		}
}